package org.wheres2.core.contactlist;

import android.location.Location;

/**
 * La classe implementa l'interfaccia ContactManager 
 * @author 
 *
 */
public class Contact implements ContactManager {

	
	private boolean online;
	private String username;
	private String name;
	private String request;
	private String sent;
	private Location location;
	
	public Contact(String username, String name) throws InvalidContactNameException {
		
		if(!username.contains("@"))
			throw new InvalidContactNameException("Invalid name format:"+ name +"; it must be a JID!");
		else{
			this.username = username;
			this.name = name;
			this.request = Boolean.toString(false);
			this.sent = Boolean.toString(false);
			this.location = null;
		}
	}
	
	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#setPresence(boolean)
	 * 
	 */
	@Override
	public void setPresence(boolean online) {
		this.online = online;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#getPresence()
	 * 
	 */
	@Override
	public boolean getPresence() {
		
		return this.online;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#getName()
	 * 
	 */
	@Override
	public String getName() {
		return this.name;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#getUserName()
	 * 
	 */
	@Override
	public String getUserName() {
		
		return this.username;
	}

	/**
	 *
	 * @see org.wheres2.core.contactlist.ContactManager#setName(java.lang.String)
	 * 
	 */
	@Override
	public void setName(String name) {
		this.name = name;
		
	}
	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#getLocation()
	 * 
	 */
	@Override
	public Location getLocation() {
		return location;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#setLocation(android.location.Location)
	 * 
	 */
	@Override
	public void setLocation(Location location) {
		this.location = location;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#getRequest()
	 * 
	 */
	@Override
	public String getRequest() {
	
		return this.request;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#setSent(java.lang.String)
	 * 
	 */
	@Override
	public void setSent(String sent) {
		this.sent = sent;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#getSent()
	 * 
	 */
	@Override
	public String getSent() {
		return this.sent;
	}

	/**
	 * 
	 * @see org.wheres2.core.contactlist.ContactManager#setRequest(java.lang.String)
	 * 
	 */
	@Override
	public void setRequest(String request) {
		this.request = request;
		
	}


}
